home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 July / CD 3 / redhat-6.2.iso / RedHat / instimage / usr / lib / anaconda / tree.py < prev    next >
Encoding:
Python Source  |  2000-03-08  |  499 b   |  17 lines

  1. def build_tree (x):
  2.     if (x == ()): return ()
  3.     if (len (x) == 1): return (x[0],)
  4.     else: return (x[0], build_tree (x[1:]))
  5.  
  6. def merge (a, b):
  7.     if a == (): return build_tree (b)
  8.     if b == (): return a
  9.     if b[0] == a[0]:
  10.         if len (a) > 1 and isinstance (a[1], type (())):
  11.             return (a[0],) + (merge (a[1], b[1:]),) + a[2:]
  12.         elif b[1:] == (): return a
  13.         else: return (a[0],) + (build_tree (b[1:]),) + a[1:]
  14.     else:
  15.         return (a[0],) + merge (a[1:], b)
  16.  
  17.